package syncAsync;

import java.io.UnsupportedEncodingException;
import java.util.Date;

import org.junit.Test;

import com.alibaba.rocketmq.client.exception.MQBrokerException;
import com.alibaba.rocketmq.client.exception.MQClientException;
import com.alibaba.rocketmq.client.producer.DefaultMQProducer;
import com.alibaba.rocketmq.client.producer.SendCallback;
import com.alibaba.rocketmq.client.producer.SendResult;
import com.alibaba.rocketmq.common.message.Message;
import com.alibaba.rocketmq.remoting.common.RemotingHelper;
import com.alibaba.rocketmq.remoting.exception.RemotingException;

public class ProducerTest1 {
    public static void main(String[] args) throws MQClientException {
        DefaultMQProducer producer = new DefaultMQProducer("rmp-group");
        producer.setNamesrvAddr("127.0.0.1:9876");
        producer.setInstanceName("rmp-instance");
        producer.setVipChannelEnabled(false);
        producer.start();
        System.out.println("start to send message");
        try {
            for (int i = 0; i < 3; i++) {
                Message msg = new Message("test1", "TagA", (new Date() + "this is a message" + i).getBytes());
                SendResult sendResult = producer.send(msg);
                System.out.println("send ok");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        producer.shutdown();


    }

    @Test
    public static void syncProducer() throws MQClientException, UnsupportedEncodingException, RemotingException, MQBrokerException, InterruptedException {

    }

    @Test
    public void asyncProducer() throws MQClientException, RemotingException, InterruptedException, UnsupportedEncodingException {

    }

    @Test
    public void onewayProducer() throws MQClientException, UnsupportedEncodingException, RemotingException, InterruptedException {

    }
}
